Skip to main content

Create Orders

Type: POST

Description: /future/trade/v1/order/create

Content-Type = application/x-www-form-urlencoded && application/json

Parameters

NameTypeMandatoryDefaultDescriptionRanges
clientOrderIdstringfalseN/AClient order ID
symbolstringtrue-Trading pair
orderSidestringtrueN/AOrder sideBUY;SELL
orderTypestringtrueN/AOrder typeLIMIT;MARKET
origQtynumbertrueN/AQuantity (Cont)
pricenumberfalseN/APrice
timeInForcestringfalseGTCValid wayGTC;IOC;FOK;GTX
triggerProfitPricenumberfalseN/AStop profit price
triggerStopPricenumberfalseN/AStop loss price
positionSidestringtrueN/APosition sideLONG;SHORT

Limit Flow Rules

200/s/apikey

OrigQty Calculation Formula

Formula

origQty = Truncate((Balance * Percent * Leverage) / (Mark_price * Contract_size))

Explanation

  • Truncate: Take the integer part (discard decimals).
  • Balance: (walletBalance - openOrderMarginFrozen) , API: /future/user/v1/compat/balance/list
  • Percent: User input value, e.g., 0.2
  • Leverage: Leverage multiplier, e.g., 20
  • Mark_price: Market mark price, e.g., 88888 (btc_usdt)
  • Contract_size: Contract face value, API: /future/market/v1/public/symbol/detailContract multiplier (face value)

Example

truncate(10000 * 0.2 * 20 / 88888 / 0.0001) = 4500

Request Example

Request
REQUEST_BODY='{
"symbol":"eth_usdt",
"origQty":1,
"positionSide":"LONG",
"orderType":"LIMIT"
}'

# The following five parameters are required

curl -X POST "https://fapi.xt.com/future/trade/v1/order/create" -H "validate-appkey: $APPKEY" # Required
-H "validate-timestamp: $TIMESTAMP" # Required
-H "validate-singature: $SINGATURE" # Required
-H "Content-Type: application/json" # Required
-d "$REQUEST_BODY"

Response Example

Response
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {},
"returnCode": 0
}

Error Codes

Error CodeDescription
contract_not_openContract not opened
exist_bonus_positon_not_create_reverse_positionUnable to create reverse position
account_errorAccount has no trial fund permission
symbol_is_not_open_positionTrading pair is not open
invalid_paramsInvalid parameters
invalid_quantity_scaleorigQty must be an integer
coupon_unavailableCoupon unavailable
welfare_coupon_not_existCoupon does not exist
coupon_exceed_max_leverageCoupon exceeds maximum leverage
exceed_max_leverageExceeds maximum leverage
gateway_decommission_ip_countryUnfortunately, our services are not available to users from restricted countries/regions. Please contact customer support if you have any questions.
gateway_decommission_kyc_countryUnfortunately, our services are not available to users from restricted countries/regions. Please contact customer support if you have any questions.
GATEWAY_0003The user has triggered risk control; your operation is temporarily prohibited.
GATEWAY_0006Your account has been locked for【{hour} hours and {minutes} minutes】due to triggering risk control rules. Please contact customer service or your account manager if you have any questions.
GATEWAY_0007Your account has been locked for【{minutes} minutes】due to triggering risk control rules. Please contact customer service or your account manager if you have any questions.